﻿using Microsoft.AspNetCore.Mvc;
using SmartAnswerPlatform.IService.System;
using SmartAnswerPlatform.Models.Entitys.System;
using SmartAnswerPlatform.Models.RequestModels;
using SmartAnswerPlatform.Models.ViewModels.System;

namespace SmartAnswerPlatform.WebApi.Controllers.System
{
    [Route("user")]
    public class SysUserController : BaseController
    {
        private readonly ISysUserService _sysUserService;

        public SysUserController(ISysUserService sysUserService)
        {
            _sysUserService = sysUserService;
        }

        [HttpPost("findAll")]
        public async Task<ActionResult> FindAll()
        {
            return Success(await _sysUserService.FindAll());
        }

        [HttpPost("add")]
        public async Task<ActionResult> Add([FromBody] SysUserViewModel userViewModel)
        {
            return Success(await _sysUserService.Insert(userViewModel));
        }

        [HttpPost("update")]
        public async Task<ActionResult> update([FromBody] SysUserViewModel userViewModel)
        {
            return Success(await _sysUserService.Update(userViewModel));
        }

        [HttpPost("delete")]
        public async Task<ActionResult> delete([FromBody] IdRequestModels idRequest)
        {
            return Success(await _sysUserService.Delete(idRequest.Id));
        }
    }
}
